Only try to pack icon if there actually is one.
authorSoeren Sandmann <sandmann@daimi.au.dk>
Sat, 24 Jan 2004 22:29:18 +0000 (22:29 +0000)
committerSøren Sandmann Pedersen <ssp@src.gnome.org>
Sat, 24 Jan 2004 22:29:18 +0000 (22:29 +0000)
Sat Jan 24 23:17:27 2004  Soeren Sandmann  <sandmann@daimi.au.dk>

* gtk/gtktoolbutton.c (gtk_tool_button_construct_contents): Only
try to pack icon if there actually is one.

* gtk/gtktoolbar.c (gtk_toolbar_size_allocate): Make sure
OVERFLOWN items get an allocation even when they are
unmapped. This ensures they will slide in properly.

* gtk/gtktoolbar.c (slide_idle_handler): Make sure we return TRUE
when there are overflown items that need to slide in. Also add
comments and make formatting more readable.

ChangeLog
ChangeLog.pre-2-10
ChangeLog.pre-2-4
ChangeLog.pre-2-6
ChangeLog.pre-2-8
gtk/gtktoolbar.c
gtk/gtktoolbutton.c

index 7c4ba995bf4b4e270289dbab25f1530bf6416b56..9fa316b817200d813e70ef5ea404ab5afaed2110 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,16 @@
+Sat Jan 24 23:17:27 2004  Soeren Sandmann  <sandmann@daimi.au.dk>
+
+       * gtk/gtktoolbutton.c (gtk_tool_button_construct_contents): Only
+       try to pack icon if there actually is one.
+
+       * gtk/gtktoolbar.c (gtk_toolbar_size_allocate): Make sure
+       OVERFLOWN items get an allocation even when they are
+       unmapped. This ensures they will slide in properly.
+
+       * gtk/gtktoolbar.c (slide_idle_handler): Make sure we return TRUE
+       when there are overflown items that need to slide in. Also add
+       comments and make formatting more readable.
+
 Sat Jan 24 17:38:48 2004  Soeren Sandmann  <sandmann@daimi.au.dk>
 
        * gtk/gtkradiotoolbutton.c (gtk_radio_tool_button_class_init):
index 7c4ba995bf4b4e270289dbab25f1530bf6416b56..9fa316b817200d813e70ef5ea404ab5afaed2110 100644 (file)
@@ -1,3 +1,16 @@
+Sat Jan 24 23:17:27 2004  Soeren Sandmann  <sandmann@daimi.au.dk>
+
+       * gtk/gtktoolbutton.c (gtk_tool_button_construct_contents): Only
+       try to pack icon if there actually is one.
+
+       * gtk/gtktoolbar.c (gtk_toolbar_size_allocate): Make sure
+       OVERFLOWN items get an allocation even when they are
+       unmapped. This ensures they will slide in properly.
+
+       * gtk/gtktoolbar.c (slide_idle_handler): Make sure we return TRUE
+       when there are overflown items that need to slide in. Also add
+       comments and make formatting more readable.
+
 Sat Jan 24 17:38:48 2004  Soeren Sandmann  <sandmann@daimi.au.dk>
 
        * gtk/gtkradiotoolbutton.c (gtk_radio_tool_button_class_init):
index 7c4ba995bf4b4e270289dbab25f1530bf6416b56..9fa316b817200d813e70ef5ea404ab5afaed2110 100644 (file)
@@ -1,3 +1,16 @@
+Sat Jan 24 23:17:27 2004  Soeren Sandmann  <sandmann@daimi.au.dk>
+
+       * gtk/gtktoolbutton.c (gtk_tool_button_construct_contents): Only
+       try to pack icon if there actually is one.
+
+       * gtk/gtktoolbar.c (gtk_toolbar_size_allocate): Make sure
+       OVERFLOWN items get an allocation even when they are
+       unmapped. This ensures they will slide in properly.
+
+       * gtk/gtktoolbar.c (slide_idle_handler): Make sure we return TRUE
+       when there are overflown items that need to slide in. Also add
+       comments and make formatting more readable.
+
 Sat Jan 24 17:38:48 2004  Soeren Sandmann  <sandmann@daimi.au.dk>
 
        * gtk/gtkradiotoolbutton.c (gtk_radio_tool_button_class_init):
index 7c4ba995bf4b4e270289dbab25f1530bf6416b56..9fa316b817200d813e70ef5ea404ab5afaed2110 100644 (file)
@@ -1,3 +1,16 @@
+Sat Jan 24 23:17:27 2004  Soeren Sandmann  <sandmann@daimi.au.dk>
+
+       * gtk/gtktoolbutton.c (gtk_tool_button_construct_contents): Only
+       try to pack icon if there actually is one.
+
+       * gtk/gtktoolbar.c (gtk_toolbar_size_allocate): Make sure
+       OVERFLOWN items get an allocation even when they are
+       unmapped. This ensures they will slide in properly.
+
+       * gtk/gtktoolbar.c (slide_idle_handler): Make sure we return TRUE
+       when there are overflown items that need to slide in. Also add
+       comments and make formatting more readable.
+
 Sat Jan 24 17:38:48 2004  Soeren Sandmann  <sandmann@daimi.au.dk>
 
        * gtk/gtkradiotoolbutton.c (gtk_radio_tool_button_class_init):
index 7c4ba995bf4b4e270289dbab25f1530bf6416b56..9fa316b817200d813e70ef5ea404ab5afaed2110 100644 (file)
@@ -1,3 +1,16 @@
+Sat Jan 24 23:17:27 2004  Soeren Sandmann  <sandmann@daimi.au.dk>
+
+       * gtk/gtktoolbutton.c (gtk_tool_button_construct_contents): Only
+       try to pack icon if there actually is one.
+
+       * gtk/gtktoolbar.c (gtk_toolbar_size_allocate): Make sure
+       OVERFLOWN items get an allocation even when they are
+       unmapped. This ensures they will slide in properly.
+
+       * gtk/gtktoolbar.c (slide_idle_handler): Make sure we return TRUE
+       when there are overflown items that need to slide in. Also add
+       comments and make formatting more readable.
+
 Sat Jan 24 17:38:48 2004  Soeren Sandmann  <sandmann@daimi.au.dk>
 
        * gtk/gtkradiotoolbutton.c (gtk_radio_tool_button_class_init):
index b1b004092ae514468f44f3e091be33b09218eebc..2141880a519334dc5fe24543d910e95ec31e7b9c 100644 (file)
@@ -1051,21 +1051,51 @@ slide_idle_handler (gpointer data)
       ItemState state;
       GtkAllocation goal_allocation;
       GtkAllocation allocation;
-      
+      gboolean cont;
+
       state = toolbar_content_get_state (content);
       toolbar_content_get_goal_allocation (content, &goal_allocation);
       toolbar_content_get_allocation (content, &allocation);
       
-      if ((state == NOT_ALLOCATED) ||
-         (state == NORMAL &&
-          toolbar_content_child_visible (content) &&
-          ((goal_allocation.x != allocation.x ||
-            goal_allocation.y != allocation.y ||
-            goal_allocation.width != allocation.width ||
-            goal_allocation.height != allocation.height))) ||
-         (toolbar_content_is_placeholder (content) &&
+      cont = FALSE;
+      
+      if (state == NOT_ALLOCATED)
+       {
+         /* an unallocated item means that size allocate has to
+          * called at least once more
+          */
+         cont = TRUE;
+       }
+
+      if ((state == NORMAL && toolbar_content_child_visible (content)) ||
+         state == OVERFLOWN)
+       {
+         if ((goal_allocation.x != allocation.x ||
+              goal_allocation.y != allocation.y ||
+              goal_allocation.width != allocation.width ||
+              goal_allocation.height != allocation.height))
+           {
+             /* An item is simply not in its right position yet. Note
+              * that OVERFLOWN items still get an allocation in
+              * gtk_toolbar_size_allocate(). This way you can see
+              * them slide in when you drag out of the toolbar
+              */
+             cont = TRUE;
+           }
+       }
+
+      if ((toolbar_content_is_placeholder (content) &&
           toolbar_content_disappearing (content) &&
-          toolbar_content_child_visible (content)))
+          (state == OVERFLOWN || toolbar_content_child_visible (content))))
+       {
+         /* A placeholder is disappearing, and it either hasn't disappeared
+          * yet, or is outside the toolbar.
+          */
+
+         cont = TRUE;
+       }
+
+      if (cont)
        {
          gtk_widget_queue_resize_no_redraw (GTK_WIDGET (toolbar));
          
@@ -1140,8 +1170,9 @@ gtk_toolbar_begin_sliding (GtkToolbar *toolbar)
       state = toolbar_content_get_state (content);
       toolbar_content_get_allocation (content, &item_allocation);
       
-      if (state == NORMAL &&
-         rect_within (&item_allocation, &(widget->allocation)))
+      if ((state == NORMAL &&
+          rect_within (&item_allocation, &(widget->allocation))) ||
+         state == OVERFLOWN)
        {
          new_start_allocation = item_allocation;
        }
@@ -1334,6 +1365,7 @@ gtk_toolbar_size_allocate (GtkWidget     *widget,
        {
          overflowing = TRUE;
          new_states[i] = OVERFLOWN;
+         allocations[i].width = item_size;
        }
     }
   
@@ -1384,7 +1416,11 @@ gtk_toolbar_size_allocate (GtkWidget     *widget,
   pos = border_width;
   for (list = priv->content, i = 0; list != NULL; list = list->next, ++i)
     {
-      if (new_states[i] == NORMAL)
+      /* both NORMAL and OVERFLOWN items get a position. This ensures
+       * that sliding will work for OVERFLOWN items too
+       */
+      if (new_states[i] == NORMAL ||
+         new_states[i] == OVERFLOWN)
        {
          allocations[i].x = pos;
          allocations[i].y = border_width;
@@ -1477,6 +1513,8 @@ gtk_toolbar_size_allocate (GtkWidget     *widget,
       if (new_states[i] != NORMAL)
        {
          toolbar_content_set_child_visible (content, toolbar, FALSE);
+         if (new_states[i] == OVERFLOWN)
+           toolbar_content_size_allocate (content, &allocations[i]);
        }
       else
        {
@@ -1500,7 +1538,7 @@ gtk_toolbar_size_allocate (GtkWidget     *widget,
            {
              alloc = allocations[i];
            }
-         
+
          if (alloc.width == 0 || alloc.height == 0)
            {
              toolbar_content_set_child_visible (content, toolbar, FALSE);
@@ -1511,7 +1549,7 @@ gtk_toolbar_size_allocate (GtkWidget     *widget,
              toolbar_content_size_allocate (content, &alloc);
            }
        }
-      
+         
       toolbar_content_set_state (content, new_states[i]);
     }
   
index 91f5a7c23f23b2085affebbc5ae179a66d1a3e28..516f93c3b7a6cd6ac7d80167f6f6f643ddeada29 100644 (file)
@@ -387,7 +387,8 @@ gtk_tool_button_construct_contents (GtkToolItem *tool_item)
 
     case GTK_TOOLBAR_BOTH_HORIZ:
       box = gtk_hbox_new (FALSE, 0);
-      gtk_box_pack_start (GTK_BOX (box), icon, label? FALSE : TRUE, TRUE, 0);
+      if (icon)
+       gtk_box_pack_start (GTK_BOX (box), icon, label? FALSE : TRUE, TRUE, 0);
       if (label)
        gtk_box_pack_start (GTK_BOX (box), label, TRUE, TRUE, 0);
       gtk_container_add (GTK_CONTAINER (button->priv->button), box);